$(function(){
	var operation = getParam("operation")||'';
	$("#operation").val(operation);
    //点击更新验证码
    $("#refresh").click(function(){
		$("#vCode").attr("src","/common/getVerifyCode.do?time="+ new Date().getTime());
	});
    //点击下一步触发事件
    $(".update-btn").click(function(){
        var name = $("#name").val()||'';
        if(name == ""){
            $(".nameSpan").show();
            return false;
        }
        $(".nameSpan").hide();
        var contactName = $("#contactname").val()||'';
        if(contactName == ""){
            $(".userNameSpan").show();
            return false;
        }
        $(".userNameSpan").hide();
        var email = $("#email").val()||'';
        if(email == ""){
            $(".emailSpan").show();
            return false;
        }
        $(".emailSpan").hide();
        var phone = $("#phone").val()||'';
        if(phone == ""){
            $(".phoneSpan").show();
            return false;
        }
        $(".phoneSpan").hide();
        var reason = $("#reason").val()||'';
        if(reason == ""){
            $(".reasonSpan").show();
            return false;
        }
        $(".reasonSpan").hide();
        //验证码校验
    	if(!verifyCodeCheck()){
         	return false;
        }
    	//.serialize()自动调用了encodeURIComponent方法将数据编码了,所以要：调用decodeURIComponent(XXX,true);将数据解码
    	window.location.href="uploadIdCard_manual.html?"+encryptParam(decodeURIComponent($('#baseInfoForm').serialize(),true));
    })
});
function verifyCodeCheck(){
	//页面输入的验证码
    var verifyCode = $('#verify').val()||'';
    if(!verifyCode){
    	$(".verifySpan").show();
        return false;
    }
    if(verifyCode.length!=4){
    	$(".verifySpan").text('验证码错误').show();
        return false;
    }
    var right = true;
    $.ajax({
    	url: "/common/checkVerifyCode.do",
    	data: {"vCode":verifyCode},
    	dataType: "json",
    	async: false,
    	success: function (data) {
    		if(data&&data.returnFlag == 'fail'){
				$(".verifySpan").text(data.msg).show();
				right = false;
    		}else{
    			$(".verifySpan").hide();
    		}
    	}
    });
    return right;
}
